package eSn.File;

import java.io.*;
/***
 * 文件基类，处理与系统层面的交互，与文件内容无关
 * @author Administrator
 *
 */
public class eSnFile {
	protected String filename;
	protected File file;
	protected String charset;
	
	public eSnFile(String FileName , CharSet cs){
		this.filename = FileName;
		file = new File(this.filename);
		switch (cs) {
		case UTF8:
			charset = "UTF-8";
			break;
		// TODO 编码方式待增加
		//case :
		//	break;
		default:
			charset = "";
			break;
		}
	}
	
	public boolean isExists(){
		return file.exists();
	}
	
	public void Delete(){
		if(file.exists()) file.delete();
	}
	
	public void CreatFile() throws IOException {
		file.createNewFile();
	}
	
	public void CreatDir(){
		file.mkdir();
	}
	
	public boolean isRead(){
		return file.canRead();
	}
	
	public boolean isWrite(){
		return file.canWrite();
	}
	
	public boolean isExecute(){
		return file.canExecute();
	}
	
	public boolean isFile(){
		return file.isFile();
	}
	
	public boolean isDir(){
		return file.isDirectory();
	}	
	
	public boolean isHidden(){
		return file.isHidden();
	}	
		
	public long Length(){
		return file.length();
	}
	
	
	
}
